<?php

class Model_Mail_RegistrationConfirmation extends Model_Mail
{
    public function __construct($options)
    {
        parent::__construct();

        $request         = Zend_Controller_Front::getInstance()->getRequest();
        $viewsPath       = '../application/' . $request->getModuleName() .
                           '/views/scripts/' . $request->getControllerName() . '/';
        $confirmationUrl = 'http://' . $_SERVER['HTTP_HOST'] .
                           '/user/registration/confirmation/key/' . $options['confirmationKey'];

        $textVersion = new Zend_View();
        $textVersion->setScriptPath($viewsPath);
        $textVersion->toName = $options['toName'];
        $textVersion->confirmationKey = $options['confirmationKey'];
        $textVersion->confirmationUrl = $confirmationUrl;

        $htmlVersion = new Zend_View();
        $htmlVersion->setScriptPath($viewsPath);
        $htmlVersion->toName = $options['toName'];
        $htmlVersion->confirmationKey = $options['confirmationKey'];
        $htmlVersion->confirmationUrl = $confirmationUrl;

        $this->addTo($options['to'], $options['toName']);
        $this->setSubject('Myzf registration confirmation');
        $this->setBodyText($textVersion->render('confirmationTextEmail.phtml'));
        $this->setBodyHtml($htmlVersion->render('confirmationHtmlEmail.phtml'));
    }
}
